/************************************************************************
 * @file StandardToolBarManager.cpp
 * @author Ian Chen
 * @version 1.0
 *
 * @section LICENSE
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 3 of
 * the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser
 * General Public License for more details at
 * http://www.gnu.org/licenses/lgpl.html
 *
 ************************************************************************/
#include <QToolBar>

#include <pluginui/manager/spi/StandardToolBarManager.h>

namespace antu
{
namespace plugin
{
namespace ui
{
StandardToolBarManager::StandardToolBarManager(QMainWindow* pMainWindow)
    : AbstractToolBarManager(),
      m_pMainWindow(pMainWindow)
{
    Q_ASSERT(this->m_pMainWindow != nullptr);
}

AbstractToolBar* StandardToolBarManager::createToolBar(const QString &name)
{
    QToolBar* pToolBar = this->m_pMainWindow->addToolBar(name);
    pToolBar->setObjectName(name);
    StandardToolBar* pBar = new StandardToolBar(pToolBar);
    return pBar;
}

StandardToolBar::StandardToolBar(QToolBar *pToolBar)
    : AbstractToolBar(pToolBar)
{
    Q_ASSERT(pToolBar != nullptr);
}

StandardToolBar::~StandardToolBar()
{

}

void StandardToolBar::addSeparator()
{
    this->toolBar()->addSeparator();
}

void StandardToolBar::appendWidget(QWidget *pWidget, int /*stretch*/)
{
    this->toolBar()->addWidget(pWidget);
}

}
}
}

